package com.css.fxfzaqbz.modules.domain.controller;

import com.css.fxfzaqbz.base.response.RestResponse;
import com.css.fxfzaqbz.modules.assess2.entity.KeyplaceRiskassessment;
import com.css.fxfzaqbz.modules.domain.service.AssessmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 单个安保活动-地震灾害风险等级量化评估
 */
@RestController
@RequestMapping("/fxfzaqbz/domain")
@Slf4j
public class AssessmentController {
    @Resource
    AssessmentService assessmentService;
    /**
     * 根据 iaId 查询需紧急安置人员 已提交
     * @param iaId 活动id
     * @return 需紧急安置人员数据
     */
    @GetMapping("/getAzByIaId/{iaId}")
    public RestResponse getAzByIaId(@PathVariable String iaId) {
        RestResponse restResponse = null;
        try {
            restResponse = RestResponse.succeed(assessmentService.getAzByIaId(iaId));
        } catch (Exception e) {
            log.error("查询需紧急安置人员数据失败!", e);
            restResponse = RestResponse.fail("查询需紧急安置人员数据失败");
        }
        return restResponse;
    }


    /**
     * 根据活动id全查询重点场所风险评估
     * @param id 活动id
     * @return
     */
    @GetMapping("/getZdByIaId/{iaId}")
    public RestResponse getZdByIaId(@PathVariable("iaId") String id) {

        RestResponse restResponse = null;
        try {
            restResponse = RestResponse.succeed(assessmentService.getZdByIaId(id));
        } catch (Exception e) {
            log.error("查询重点场所风险评估失败!", e);
            restResponse = RestResponse.fail("查询重点场所风险评估失败");
        }
        return restResponse;
    }

    /**
     * 查询人口伤亡数据失败
     * @param id 活动id
     * @return
     */
    @GetMapping("/getCasualtiesByIaId/{id}")
    public RestResponse getCasualtiesByIaId(@PathVariable("id") String id) {

        RestResponse restResponse = null;
        try {
            restResponse = RestResponse.succeed(assessmentService.getCasualtiesByIaId(id));
        } catch (Exception e) {
            log.error("查询人口伤亡数据失败!", e);
            restResponse = RestResponse.fail("查询人口伤亡数据失败");
        }
        return restResponse;
    }



    /**
     * 查询房屋失败
     * @param id 活动id
     * @return
     */
    @GetMapping("/getDisasterAssByIaId/{id}")
    public RestResponse getDisasterAssByIaId(@PathVariable("id") String id) {

        RestResponse restResponse = null;
        try {
            restResponse = RestResponse.succeed(assessmentService.getDisasterAssByIaId(id));
        } catch (Exception e) {
            log.error("查询房屋失败!", e);
            restResponse = RestResponse.fail("查询房屋失败");
        }
        return restResponse;
    }

    /**
     * 查询地震趋势数据失败
     * @param id 活动id
     * @return
     */
    @GetMapping("/getRiskAssessmentByIaId/{id}")
    public RestResponse getRiskAssessmentByIaId(@PathVariable("id") String id) {

        RestResponse restResponse = null;
        try {
            restResponse = RestResponse.succeed(assessmentService.getRiskAssessmentByIaId(id));
        } catch (Exception e) {
            log.error("查询地震趋势数据失败!", e);
            restResponse = RestResponse.fail("查询地震趋势数据失败");
        }
        return restResponse;
    }


    /**
     * 查询二次灾害数据失败
     * @param id 活动id
     * @return
     */
    @GetMapping("/getSecondDisastersByIaId/{id}")
    public RestResponse getSecondDisastersByIaId(@PathVariable("id") String id) {

        RestResponse restResponse = null;
        try {
            restResponse = RestResponse.succeed(assessmentService.getSecondDisastersByIaId(id));
        } catch (Exception e) {
            log.error("查询二次灾害数据失败!", e);
            restResponse = RestResponse.fail("查询二次灾害数据失败");
        }
        return restResponse;
    }

}
